let now = new Date();
let year = now.getFullYear();	// 得到年份
let month = now.getMonth()+1;	// 得到月份
let date = now.getDate();	// 得到日期
let hour = now.getHours();	// 得到小时
let min = Number(now.getMinutes())<=9?('0'+now.getMinutes()):now.getMinutes();	// 得到分钟
let curTime = year + "年" + (month < 10 ? "0"+month:month) + "月" + (date < 10 ? "0"+date:date) + "日" 
let curTime1 = year + "-" + (month < 10 ? "0"+month:month) + "-" +  (date < 10 ? "0"+date:date)
let curTimeAll = year + "-" + (month < 10 ? "0"+month:month) + "-" + (date < 10 ? "0"+date:date) +" " + (hour < 10 ? "0"+hour:hour) + ":"+ (min < 10 ? "0"+min:min)
let todayDay=date
let todayMonth=month
export {curTime,curTime1,curTimeAll,todayMonth,todayDay}

export const getAge=function(birthday,curDat) {
    var birthStr =birthday.replace(/-/g, '/');
    var birthDay = new Date(birthStr).getTime();
    let onDay=24*60*60*1000
    console.log(curDat,12221)
    if(curDat){
      var curDatStr =curDat.replace(/-/g, '/');
      var now = new Date(curDatStr).getTime()+onDay;
    var hours = (birthDay - now) / 1000 / 60 / 60;

    }else{
      
    var now = new Date().getTime()+onDay;
    var hours = (now - birthDay) / 1000 / 60 / 60;
    }
    var year = Math.floor(hours / (24 * 30 * 12));
    hours = hours % (24 * 30 * 12);
    var months = Math.floor(hours / (24 * 30));
    hours = hours % (24 * 30);
    var days = Math.floor(hours / 24);
    let retuAttr=days + '天'
    if(months>0){
      retuAttr=months + '月' + days + '天'
    }
    if(year>0){
      retuAttr=year + '岁' + months + '月' + days + '天'
    }
    return  retuAttr
}